package com.lxm.ymcc.web.controller;
import com.lxm.ymcc.dto.RegisterPhoneDTO;
import com.lxm.ymcc.result.JSONResult;
import com.lxm.ymcc.service.ISendCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private ISendCodeService sendCodeService;

    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageVerifyCode(@PathVariable("imageCodeKey") String imageCodeKey){

            return sendCodeService.imageVerifyCode(imageCodeKey);

    }

    @PostMapping("/sendSmsCode")
    public JSONResult sendCode(@RequestBody @Valid RegisterPhoneDTO dto){
        sendCodeService.send(dto);
        return JSONResult.success();
    }
}
